package me.jiatao.usercenter.data.respository

import io.reactivex.Observable
import me.jiatao.baselibrary.data.net.RetrofitFactory
import me.jiatao.baselibrary.data.protocol.HttpResult
import me.jiatao.usercenter.data.api.UserApi
import me.jiatao.usercenter.data.protocol.LoginReq
import me.jiatao.usercenter.data.protocol.RegisterReq
import me.jiatao.usercenter.data.protocol.UserInfo
import javax.inject.Inject

class UserRepository @Inject constructor() {
    /**
     * 用户注册
     */
    fun register(mobile: String, pwd: String, verifyCode: String): Observable<HttpResult<String>> {
        return RetrofitFactory.instance
            .create(UserApi::class.java)
            .register(RegisterReq(mobile, pwd, verifyCode))
    }

    /**
     * 用户登录
     */
    fun login(mobile: String, pwd: String): Observable<HttpResult<UserInfo>> {
        return RetrofitFactory.instance
            .create(UserApi::class.java)
            .login(LoginReq(mobile, pwd))
    }
}